package com.leyou.favorite.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.favorite.Favorite;
import com.leyou.favorite.FavoriteDto;
import com.leyou.item.entity.Brand;
import com.leyou.item.entity.Spu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface FavoriteMapper extends BaseMapper<FavoriteDto> {
    @Delete("DELETE FROM tb_favorite WHERE user_id=#{userId} and sku_id=#{skuId}")
    void deleteBySkuId(@Param("userId") long userId,@Param("skuId") Long skuId);

    @Select("SELECT * FROM tb_favorite WHERE user_id=#{userId} and sku_id=#{skuId}")
    Integer selectBySkuId(Long userId, Long skuId);

    @Select("SELECT DISTINCT spu_id FROM tb_sku WHERE id=#{skuId}")
    Long findSpuIdBySkuId(String skuId);

    @Select("select * from tb_favorite where user_id=#{userId}")
    List<FavoriteDto> findAllFavorite(Long userId);
}
